<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *会员列表
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
$tabs=array(
);

//会员列表
if($_RQ['op']=='list'){
	$params=array('merchid'=>$_SESSION['onemerchid']);
	$params['uniacid']=$_SESSION['uniacid'];
	if(!empty($_RQ['title'])){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	if(!empty($_RQ['workerid'])){
		$userid=$this->model('worker')->get_userid(intval($_RQ['workerid']));
		$params['owner']=$userid;
		$return['params']['workerid']=$_RQ['workerid'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_scrm_qun_member',$params,array($pindex,$psize),$total,$fields,'','createtime desc');
	if($list){
		foreach($list as &$item){
			$item['workername']=$this->pdo_getcolumn('worker',array('userid'=>$item['invitor_userid'],'uniacid'=>$_SESSION['uniacid']),'name');
			if(!$item['name']){
				$item['name']=$this->pdo_getcolumn('member',array('external_userid'=>$item['userid'],'uniacid'=>$_SESSION['uniacid']),'name');
			}
			$item['quntitle']=$this->pdo_getcolumn('qun',array('chat_id'=>$item['chat_id'],'uniacid'=>$_SESSION['uniacid']),'title');
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','tip'=>'[温馨提示]：同步群后，会追加群成员！','edit'=>false,'delall'=>false,'del_one'=>false,'list'=>array(
			array('name'=>'quntitle','title'=>'群名','type'=>'string'),
			array('name'=>'userid','title'=>'用户ID','type'=>'string'),
			array('name'=>'group_nickname','title'=>'群昵称','type'=>'string'),
			array('name'=>'name','title'=>'用户名称','type'=>'string'),
			array('name'=>'workername','title'=>'员工名称','type'=>'string'),
			array('name'=>'join_scene','title'=>'入群方式','type'=>'radio','options'=>'join_scene'),
			array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'qunmemberstatus'),
			array('name'=>'join_time','title'=>'入群时间','type'=>'time'),
		)),
		'search'=>array(
			array('name'=>'title','title'=>'用户名称','type'=>'string','width'=>'15'),
			array('type'=>'choose','width'=>15,'title'=>'员工成员','name'=>'workerid','action'=>'jy_scrm/worker.get_worker/'),
		),	
	);
	$return['join_scene']=$this->join_scene;
	$return['qunmemberstatus']=$this->qunmemberstatus;
	$return['htmls']=$htmls;
	exi($return);
}